package com.unionfetch.content_home.presenter

import com.unionfetch.content_home.bean.AccountCategory
import com.unionfetch.content_home.bean.TradeDataDetail
import com.unionfetch.content_home.contract.HomeContract
import com.unionfetch.content_home.model.HomeModel
import com.unionftech.common.base.mvp.impl.BasePresenter
import com.unionftech.common.base.mvp.impl.IBaseCallBack
import com.unionftech.common.bean.ResponseResult

class HomePresenter : BasePresenter<HomeContract.ITradeDataView, HomeModel>(),
    HomeContract.IHomePresenter {
    override fun getTradeDataDetail(token: String, tradeNo: String, type: AccountCategory) {
        getView()?.showLoading()
        val callBack = object : IBaseCallBack<ResponseResult<TradeDataDetail>> {
            override fun onResponse(response: ResponseResult<TradeDataDetail>) {
                getView()?.hideLoading()
                getView()?.handleTradeDataDetail(response)
            }
        }
        getModel().getTradeDataDetail(token, tradeNo, type, callBack)
    }

    override fun getFloatSurplus(token: String, tradeNo: String, type: Int) {
        getView()?.showLoading()
        getModel().getFloatSurplus(
            token,
            tradeNo,
            type,
            object : IBaseCallBack<ResponseResult<String>> {
                override fun onResponse(response: ResponseResult<String>) {
                    getView()?.hideLoading()
                    getView()?.handleFloatSurplus(response)
                }
            })
    }
}